<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Contact_model extends CI_Model{
    public function __construct() {
        parent::__construct();
        $this->load->database();
    }
    public function addMail($From,$FromFullName,$To,$Subject,$Content,$AttachFile)
    {
        $add_mail=array(
            'To'=>$To,
            'FromFullName'=>$FromFullName,
            'From'=>$From,
            'Subject'=>$Subject,
            'Content'=>$Content,
            'AttachFile'=>$AttachFile
        );
        $addmail=$this->db->insert('Contact',$add_mail);
        return $addmail;
    }
    public function getListSendMail($From)
    {
        $this->db->where('From',$From);
        $query=$this->db->get('Contact');
        return $query;
    }
    public function getListSendMailLimited($From,$per_page,$start_row)
    {
        $this->db->where('From',$From);
        $query=$this->db->get('Contact',$per_page,$start_row);
        return $query;
    }
    public function getListInbox($To)
    {
       $this->db->where('To',$To);
       $query=$this->db->get('Contact');
       return $query; 
    }
    public function getListInboxLimited($To,$per_page,$start_row)
    {
       $this->db->where('To',$To);
       $query=$this->db->get('Contact',$per_page,$start_row);
       return $query; 
    }
    public function getContactByContactID($Contact_ID)
    {
        $this->db->where('Contact_ID',$Contact_ID);
        $query=$this->db->get('Contact');
        return $query;
    }
    public function deleteMail($Contact_ID)
    {
        $this->db->where('Contact_ID',$Contact_ID);
        $this->db->delete('Contact');
    }
}
?>
